package com.android.presenter.info;

import com.android.model.entity.res.OrderResult;
import com.android.model.net.HttpObserver;
import com.android.presenter.base.BasePresenter;
import com.android.presenter.iview.IOpenOrderView;
import com.android.model.info.UserModel;
import com.android.util.log.LogUtil;

import java.util.List;

/**
 * author:  TenFace
 * date:    2017/9/27
 * description: 未成交的订单
 */

public class OpenOrderPresenter extends BasePresenter<IOpenOrderView> {

    private static final String TAG = OpenOrderPresenter.class.getSimpleName();
    private UserModel mUserModel;

    public OpenOrderPresenter(IOpenOrderView iOpenOrderView) {
        super(iOpenOrderView);
        mUserModel = UserModel.getInstance();
    }

    public void getListOpenOrder(String accountId, String token) {

        mUserModel.getListOpenOrder(accountId, token, new HttpObserver<List<OrderResult>>() {
            @Override
            public void onSuccess(List<OrderResult> orderResultList) {
                LogUtil.e(TAG, "成功！");
                if (mIView != null) {
                    mIView.orderOpenSuccess(orderResultList);
                }
            }

            @Override
            public void onError(int errType, String errMessage) {
                LogUtil.e(TAG, "失败码：" + errType + "》》信息：" + errMessage);
                if (mIView != null) {
                    mIView.orderOpenFail(errType, errMessage);
                }
            }
        }, mIView.getLifeSubject());
    }

}
